package com.wuyou.convert;

import com.wuyou.dto.HouseInputInfoDTO;
import com.wuyou.entity.Community;
import com.wuyou.entity.House;
import com.wuyou.entity.HouseDetails;

/**
 * ClassName ConvertDtoToDO
 * Description
 * Author chenxy9606@163.com
 * Date 2022/10/2 17:22
 * Version 1.0
 **/
public class ConvertDtoToDO {




    public static Community convert2Community(HouseInputInfoDTO houseInputInfoDTO) {
        return Community.builder()
                .property(houseInputInfoDTO.getProperty())
                .propertyFee(houseInputInfoDTO.getPropertyFee())
                .communityName(houseInputInfoDTO.getCommunityName())
                .build();
    }

    public static House convert2House(HouseInputInfoDTO houseInputInfoDTO) {
        return House.builder().houseImage(houseInputInfoDTO.getHouseImage())
                .houseType(houseInputInfoDTO.getHouseType())
                .payType(houseInputInfoDTO.getPayType())
                .title(houseInputInfoDTO.getTitle())
                .rent(houseInputInfoDTO.getRent())
                .houseId(houseInputInfoDTO.getHostId())
                .build();
    }

    public static HouseDetails convert2HouseDetail(HouseInputInfoDTO houseInputInfoDTO,Long houseId,Long communityId) {
        return HouseDetails.builder().houseId(houseId)
                .provinceid(houseInputInfoDTO.getProvinceid())
                .cityid(houseInputInfoDTO.getCityid())
                .areaid(houseInputInfoDTO.getAreaid())
                .area(houseInputInfoDTO.getArea())
                .address(houseInputInfoDTO.getAddress())
                .communityId(communityId)
                .introduction(houseInputInfoDTO.getIntroduction())
                .build();
    }
}
